package com.example.fridaykt.service.impl

import com.example.fridaykt.model.SysRole
import com.example.fridaykt.model.roleSort
import com.example.fridaykt.repository.SysRoleRepository
import com.example.fridaykt.service.SysRoleService
import com.example.fridaykt.vo.Page
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

/**
 * @author 27371
 * @description 针对表【sys_role(角色信息表)】的数据库操作Service实现
 * @createDate 2022-05-09 17:21:41
 */
@Service
@Transactional
class SysRoleServiceImpl(
    private val sysRoleRepository: SysRoleRepository,
) : SysRoleService {
    override fun getRoleList(cur: Int, ps: Int): Page<SysRole> {
        val res = sysRoleRepository.sql.createQuery(SysRole::class) {
            orderBy(table.roleSort)
            select(table)
        }.fetchPage(cur - 1, ps)

        return Page<SysRole>().apply {
            current = cur
            pageSize = ps
            records = res.rows
            total = res.totalPageCount
        }
    }
}




